module EventEditor
  class WaitInputDialog
   def self.show(base, &func)
     dialog = Gtk::Dialog.new("Wait Frames",
             base,
             Gtk::Dialog::MODAL |
             Gtk::Dialog::DESTROY_WITH_PARENT,
             ["OK", Gtk::Dialog::RESPONSE_OK],
             ["Cancel", Gtk::Dialog::RESPONSE_CANCEL]
             )

      hbox = Gtk::HBox.new
      hbox.set_border_width(5)
      hbox.add(wait_input = Gtk::SpinButton.new(0, 99, 1))
      hbox.add(Gtk::Label.new('frames'))
      dialog.vbox.add(hbox)
      dialog.vbox.show_all

      # run
      dialog.run do |response|
        if response == Gtk::Dialog::RESPONSE_OK
          func.call(wait_input.value.floor)
        else
          func.call(:cancel)
        end
        dialog.destroy
      end
    end
  end
end